<template>
  <div class="">
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in banner" :key="item.id">
        <img :src="item.picUrl" alt="" />
      </van-swipe-item>
    </van-swipe>

    <h1 @click="$router.push('/list')">精选专题</h1>
    <div class="wrap">
      <ul class="inner">
        <li v-for="item in list" :key="item.id">
          <img :src="item.pic" alt="" />
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { ref, reactive, toRefs } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
import { getBanner, getList } from "../utils/yx";
import myGood from "../components/myGood.vue";
export default {
  setup(props, ctx) {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const data = reactive({
      banner: [],
      list: [],
    });
    getBanner().then((res) => {
      data.banner = res.data;
    });
    //获取轮播图

    getList().then((res) => {
      console.log(res);
      data.list = res.data;
    });

    return { ...toRefs(data) };
  },
  components: {
    myGood,
  },
};
</script>

<style lang="scss">
.wrap {
  width: 100%;
  overflow: scroll;
  .inner {
    display: flex;
    li {
      flex-shrink: 0;
      width: 400px;
      height: 200px;
      margin-right: 10px;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
}
</style>
